fis.require('jello')(fis);
fis.config.set('component.gitlab.token', 'oydA2nyPHKH1bHKzAzGa');

var gulp = require('gulp'),
  clean = require('gulp-clean');

var destPath, workPath, copy;

if (process.platform === 'linux') {
  destPath = '/home/lcat/.fis3-tmp/www';
  workPath = '/home/lcat/workspace/Eclipse-JEE-PLATFORM/hzx-website-pc/src/main/webapp';
} else if (require('os').hostname() == 'lyg-PC') {
  destPath = 'C:\\Users\\lyg\\AppData\\Local\\\.fis3-tmp\\www';
  workPath = 'F:\\ztelyg\\hzx-mweb\\src\\main\\webapp';
} else if (require('os').hostname() == 'FeLiX-PC') {
  destPath = 'C:\\Users\\Raphael\\AppData\\Local\\\.fis3-tmp\\www';
  workPath = 'F:\\workspace\\yl-import\\yl-import-buyer\\hzx-mweb\\src\\main\\webapp';
}

fis.unhook('commonjs');
fis.hook('amd', {
  packages: [
    // 用来存放 js 库
    {
      name: 'js',
      location: 'static/js/',
      main: 'index'
    }
  ]
});

fis.on('release:end', function () {
  !!copy && setTimeout(function () {
    gulp.src(destPath + '/static/**')
      .pipe(gulp.dest(workPath + '/static'));
    // gulp.src(destPath + '/test/**')
    // .pipe(gulp.dest(workPath + '/test'))
    gulp.src([destPath + '/WEB-INF/**',
      '!' + destPath + '/WEB-INF/web.xml',
      '!' + destPath + '/WEB-INF/velocity.properties'
    ])
      .pipe(gulp.dest(workPath + '/WEB-INF'))
  }, 600)
});

fis
/*.match('/static/js/widget/!**.js',{
 isMod: true
 })*/
  .match('/static/scss/*.scss', {
    rExt: 'css',
    parser: fis.plugin('node-sass')
  })
  .match('*.{js,es,es6,jsx,ts,tsx}', {
    preprocessor: fis.plugin('js-require-css')
  });

/*测试发布*/
fis.media('pub')
  //index 打包
  .match('/static/script/{' +
    'page/base/*.js,' +
    'page/layout/*.js,' +
    'page/index.js,' +
    'widget/comm.js' +
    '}',
    {packTo: '/static/script/page/index_pack.js'})

  .match('*.js', {optimizer: fis.plugin('uglify-js')})
  .match('*.css', {optimizer: fis.plugin('clean-css')})
  .match('*.png', {optimizer: fis.plugin('png-compressor')});
